﻿<%@ Page Language="C#" AutoEventWireup="true" ValidateRequest="false" CodeFile="ProdAddNew.aspx.cs"
    Inherits="Manager_ProdAddNew" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>新增产品资料</title>
    <style type="text/css">
        .mright
        {
            margin-right: 5px;
        }
        .datecontainer .x-form-field-trigger-wrap
        {
            margin-right: 5px;
        }
        .property_ext{ width:100%;padding:0 5px;}
        .property_ext ul li{ line-height:0; font-size:0; overflow:hidden; width:100%;}
        .property_ext ul li label{ width:90px; height:22px; line-height:1.5; display:block; float:left; text-align:left; font-size:12px;}
        .property_ext ul li input{ display:block; float:left;height:20px;border:1px solid #CCC; width:200px; padding:0 5px;}
        .property_ext ul li textarea{ width:400px; height:200px; border:1px solid #CCC; padding:5px; line-height:20px;}
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <ext:PageManager ID="PageManager1" runat="server" AjaxLoadingType="mask" AutoSizePanelID="sfObject" />
        <ext:SimpleForm ID="sfObject" runat="server" ShowHeader="false" LabelAlign="left"
            BodyPadding="10px" LabelWidth="95px" AutoScroll="true" FooterBarAlign="center">
            <Items>
                <ext:Panel ID="Panel1" ShowHeader="false" CssClass="x-form-item" ShowBorder="false"
                    Layout="Column" runat="server">
                    <Items>
                        <ext:HiddenField ID="hfProdId" runat="server">
                        </ext:HiddenField>
                        <ext:Label ID="lblProdName" Width="100px" runat="server" CssClass="inline" ShowLabel="false"
                            Text="品名:">
                        </ext:Label>
                        <ext:TextBox ID="txtProdName" runat="server" EmptyText="请填写产品名称" Label="产品名称" Required="true"
                            Width="300px">
                        </ext:TextBox>
                        <ext:DropDownList ID="ddlCorpProdName" runat="server" EnableSimulateTree="true">
                        </ext:DropDownList>
                        <ext:Button ID="btnCopyProd" runat="server" Icon="PageCopy" Text="复制产品信息" OnClick="btnCopyProd_Click"
                            ConfirmText="是否确定？">
                        </ext:Button>
                    </Items>
                </ext:Panel>
                <ext:Panel ID="Panel2" ShowHeader="false" CssClass="x-form-item datecontainer" ShowBorder="false"
                    Layout="Column" runat="server">
                    <Items>
                        <ext:Label ID="Label2" Width="100px" runat="server" CssClass="inline" ShowLabel="false"
                            Text="类别：">
                        </ext:Label>
                        <ext:DropDownList ID="ddlProdClass" runat="server" EnableSimulateTree="true" Required="true">
                            <ext:ListItem Value="" Text="请选择产品类别" />
                        </ext:DropDownList>
                        <ext:Button ID="btnProdClassEdit" runat="server" Text="产品类别管理">
                        </ext:Button>
                    </Items>
                </ext:Panel>
                <ext:Panel ID="Panel3" ShowHeader="false" CssClass="x-form-item datecontainer" ShowBorder="false"
                    Layout="Column" runat="server">
                    <Items>
                        <ext:Label ID="Label3" Width="100px" runat="server" CssClass="inline" ShowLabel="false"
                            Text="编号：">
                        </ext:Label>
                        <ext:TextBox ID="txtProdCode" runat="server" EmptyText="请填写产品编号，并确定唯一性！" Required="true"
                            Width="300px" Label="编号" OnTextChanged="txtProdCode_TextChanged" AutoPostBack="true">
                        </ext:TextBox>
                    </Items>
                </ext:Panel>
                <ext:Panel ID="Panel8" ShowHeader="false" CssClass="x-form-item datecontainer" ShowBorder="false"
                    Layout="Column" runat="server">
                    <Items>
                        <ext:Label ID="lblProdProperty" Width="100px" runat="server" CssClass="inline" ShowLabel="false"
                            Text="产品属性：">
                        </ext:Label>
                        <ext:Label ID="Label1" runat="server" CssClass="inline" ShowLabel="false" Text="库存：">
                        </ext:Label>
                        <ext:TextBox ID="txtStoreAmount" runat="server" EmptyText="请填写产品库存！" Text="1" Regex="^\d+" Width="100px" Label="库存"
                            Required="true">
                        </ext:TextBox>
                        <ext:Label ID="Label12" runat="server" CssClass="inline" ShowLabel="false" Text="&nbsp;&nbsp;&nbsp;&nbsp;重量：">
                        </ext:Label>
                        <ext:TextBox ID="txtWeight" runat="server" EmptyText="请填写产品重量！" Text="1" Width="100px" Label="重量"
                            Required="true">
                        </ext:TextBox>
                        <ext:Label ID="Label20" runat="server" CssClass="inline" ShowLabel="false" Text="Kg"></ext:Label>
                    </Items>
                </ext:Panel>
                <ext:FileUpload ID="fuProdImages" runat="server" ButtonText="选择图片" Required="true"
                    EmptyText="请上传图片,图片规格：建议600*800px" Label="产品图片" Width="420">
                </ext:FileUpload>
                <ext:Panel ID="Panel6" runat="server" ShowHeader="false" ShowBorder="false" Layout="column"
                    CssClass="x-form-item datecontainer">
                    <Items>
                        <ext:Label ID="Label8" Width="100px" runat="server" CssClass="inline" ShowLabel="false"
                            Text="&nbsp;&nbsp;">
                        </ext:Label>
                        <ext:Button ID="btnUpProdImageOther" runat="server" Text="上传更多产品图片" OnClick="btnUpProdImageOther_Click">
                        </ext:Button>
                    </Items>
                </ext:Panel>
                <ext:Panel ID="Panel7" ShowHeader="false" CssClass="x-form-item datecontainer" ShowBorder="false"
                    Layout="Column" runat="server" Visible="false">
                    <Items>
                        <ext:Label ID="Label9" Width="100px" runat="server" CssClass="inline" ShowLabel="false"
                            Text="规格尺寸：">
                        </ext:Label>
                        <ext:Label runat="server" Text="长度：">
                        </ext:Label>
                        <ext:TextBox ID="txtCD" runat="server" EmptyText="仅填写数值型！" Regex="^\d+$" Width="80px"
                            Label="长">
                        </ext:TextBox>
                        <ext:Label ID="Label10" runat="server" Text="&nbsp;&nbsp;&nbsp;&nbsp;宽度：">
                        </ext:Label>
                        <ext:TextBox ID="txtKD" runat="server" EmptyText="仅填写数值型！" Regex="^\d+$" Width="80px"
                            Label="宽">
                        </ext:TextBox>
                        <ext:Label ID="Label11" runat="server" Text="&nbsp;&nbsp;&nbsp;&nbsp;高度：">
                        </ext:Label>
                        <ext:TextBox ID="txtGD" runat="server" EmptyText="仅填写数值型！" Regex="^\d+$" Width="80px"
                            Label="高">
                        </ext:TextBox>
                        <ext:Label ID="Label16" runat="server" Text="&nbsp;&nbsp;&nbsp;&nbsp;椅高：">
                        </ext:Label>
                        <ext:TextBox ID="txtYG" runat="server" EmptyText="椅子产品时填写！" Regex="^\d+$" Width="80px"
                            Label="椅高">
                        </ext:TextBox>
                        <ext:Label ID="Label17" runat="server" Text="&nbsp;&nbsp;&nbsp;&nbsp;坐深：">
                        </ext:Label>
                        <ext:TextBox ID="txtZS" runat="server" EmptyText="椅子产品时填写！" Regex="^\d+$" Width="80px"
                            Label="座深">
                        </ext:TextBox>
                        <ext:Label ID="Label18" runat="server" Text="&nbsp;&nbsp; 单位：毫米（mm）">
                        </ext:Label>
                    </Items>
                </ext:Panel>
                <%--<ext:FileUpload ID="fuProdImages1" runat="server" EmptyText="请上传图片" ButtonText="选择图片"
                    Label="产品图片1" Width="420">
                </ext:FileUpload>
                <ext:FileUpload ID="fuProdImages2" runat="server" EmptyText="请上传图片" ButtonText="选择图片"
                    Label="产品图片2" Width="420">
                </ext:FileUpload>
                <ext:FileUpload ID="fuProdImages3" runat="server" EmptyText="请上传图片" ButtonText="选择图片"
                    Label="产品图片3" Width="420">
                </ext:FileUpload>
                <ext:FileUpload ID="fuProdImages4" runat="server" EmptyText="请上传图片" ButtonText="选择图片"
                    Label="产品图片4" Width="420">
                </ext:FileUpload>
                <ext:FileUpload ID="fuProdImages5" runat="server" EmptyText="请上传图片" ButtonText="选择图片"
                    Label="产品图片5" Width="420">
                </ext:FileUpload>--%>
                <ext:Panel ID="Panel4" ShowHeader="false" CssClass="x-form-item datecontainer" ShowBorder="false"
                    Layout="Column" runat="server">
                    <Items>
                        <ext:Label ID="Label4" Width="100px" runat="server" CssClass="inline" ShowLabel="false"
                            Text="价格设定：">
                        </ext:Label>
                        <ext:Label ID="Label19" Width="100px" runat="server" CssClass="inline" ShowLabel="false"
                            Text="市场价：">
                        </ext:Label>
                        <ext:TextBox ID="txtMarketPrice" runat="server" EmptyText="请填写市场价，0为面议！" Label="市场价"
                            Required="true" Regex="^\d+(\.\d+)?$" Width="80px">
                        </ext:TextBox>
                        <ext:Label ID="Label5" Width="100px" runat="server" CssClass="inline" ShowLabel="false"
                            Text="&nbsp;&nbsp;;会员价：">
                        </ext:Label>
                        <ext:TextBox ID="txtUserPrice" runat="server" EmptyText="请填写市场价，0为面议！" Label="会员价"
                            Required="true" Regex="^\d+(\.\d+)?$" Width="80px">
                        </ext:TextBox>
                    </Items>
                </ext:Panel>
                <ext:TextArea ID="txtKeywords" runat="server" EmptyText="站点优化关键词" Label="关键词" Height="40px">
                </ext:TextArea>
                <ext:TextArea ID="txtDescription" runat="server" EmptyText="站点优化描述" Label="描述" Height="40px">
                </ext:TextArea>
                <ext:TextArea ID="txtProdInstr" runat="server" EmptyText="产品简介信息" Label="产品简介" Height="40px">
                </ext:TextArea>
                <ext:CheckBoxList ID="cboxProdExt" runat="server" Label="其它属性">
                    <ext:CheckItem Text="显示" Value="1" Selected="true" />
                    <ext:CheckItem Text="热销" Value="2" />
                    <ext:CheckItem Text="新品" Value="3" />
                </ext:CheckBoxList>
                <ext:Panel ID="Panel5" ShowHeader="false" CssClass="x-form-item datecontainer" ShowBorder="false"
                    Layout="Column" runat="server">
                    <Items>
                        <ext:Label ID="Label6" Width="100px" runat="server" CssClass="inline" ShowLabel="false"
                            Text="产品排序：">
                        </ext:Label>
                        <ext:TextBox ID="txtProdOrder" runat="server" Regex="^\d+$" Text="9999" Width="80px">
                        </ext:TextBox>
                        <ext:Label ID="Label7" Width="100px" runat="server" CssClass="inline" ShowLabel="false"
                            Text="&nbsp;&nbsp;点击数：">
                        </ext:Label>
                        <ext:TextBox ID="txtProdHits" runat="server" Regex="^\d+$" Text="0" Width="80px">
                        </ext:TextBox>
                    </Items>
                </ext:Panel>
                
                <ext:ContentPanel ID="cpProperty" runat="server" Title="附加属性" BodyPadding="5px"> 
                <%
                    Hashtable htAttr1 = new Hashtable();
                    int iSelectId = 0;
                    int.TryParse(Convert.ToString(Request.QueryString["ProdId"]), out iSelectId);
                    Model.DbProducts products = Dal.DbProductsDal.Select(iSelectId);
                    if (products != null)
                    {
                        htAttr1 = DalEx.DbProductsEx.GetHashTableProdEx(products.PCode, 3, "CN");
                    }
                    Model.DbParamsEx dbParamsEx = null;
                    System.Data.DataSet ds = DalEx.ParamsExtEx.Select();
                    if (System.Data.SqlHelper.HasRow(ds))
                    {
                        string strBindValues = string.Empty;
                        foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
                        {
                            dbParamsEx = new Model.DbParamsEx(dr);
                            if (htAttr1.ContainsKey(dbParamsEx.PName))
                                strBindValues = htAttr1[dbParamsEx.PName].ToString();
                            else
                                strBindValues = dbParamsEx.PSelectTextValue;
                            
                            Response.Write("<div class=\"property_ext\"><ul><li><label>" + dbParamsEx.PName + "：</label>");
                            switch (dbParamsEx.PFieldType)
                            {
                                case "TextBox":
                                    Response.Write("<input type=\"text\" name=\"pp_" + dbParamsEx.PName + "\" value=\"" + strBindValues + "\" style=\"width:200px;\" /></li>");
                                    break;
                                case "TextArea":
                                    Response.Write("<textarea name=\"pp_" + dbParamsEx.PName + "\" value=\"" + strBindValues + "\" style=\"width:500px;height:80px;\"></TextArea></li>");
                                    break;
                                case "DropDownList":
                                    Response.Write("<select name=\"pp_" + dbParamsEx.PName + "\">");
                                    foreach (string strValue in dbParamsEx.PTextDefaultValue.Split('|'))
                                    {
                                        if (strValue == strBindValues)
                                        {
                                            Response.Write("<option value=\"" + strValue + "\" Selected=\"Selected\">" + strValue + "</option>");
                                        }
                                        else
                                        {
                                            Response.Write("<option value=\"" + strValue + "\">" + strValue + "</option>");
                                        }
                                    }
                                    Response.Write("</select>");
                                    break;
                                case "RatioButton":
                                    foreach (string strValue in dbParamsEx.PTextDefaultValue.Split('|'))
                                    {
                                        if (strValue == strBindValues)
                                        {
                                            Response.Write("<input style=\"width:40px;border:0px; padding:0;\" type=\"radio\" name=\"pp_" + dbParamsEx.PName + "\" value=\"" + strValue + "\" checked=\"checked\" /><label style=\"width:auto;\">" + strValue + "</label>");
                                        }
                                        else
                                        {
                                            Response.Write("<input style=\"width:40px;border:0px; padding:0;\" type=\"radio\" name=\"pp_" + dbParamsEx.PName + "\" value=\"" + strValue + "\" /><label style=\"width:auto;\">" + strValue + "</label>");
                                        }
                                    }
                                    //<input type="radio" name="" />
                                    break;
                                case "CheckBox":
                                    Hashtable htSelectValue = new Hashtable();
                                    foreach (string strValue in strBindValues.Split('|'))
                                    {
                                        htSelectValue.Add(strValue, strValue); 
                                    }
                                    foreach (string strValue in dbParamsEx.PTextDefaultValue.Split('|'))
                                    {
                                        if (htSelectValue.ContainsKey(strValue))
                                            Response.Write("<input style=\"width:40px;border:0px;padding:0;\" type=\"checkbox\" name=\"pp_" + dbParamsEx.PName + "\" value=\"" + strValue + "\" checked=\"checked\" /><label style=\"width:auto;\">" + strValue + "</label>");
                                        else
                                            Response.Write("<input style=\"width:40px;border:0px;padding:0;\" type=\"checkbox\" name=\"pp_" + dbParamsEx.PName + "\" value=\"" + strValue + "\" /><label style=\"width:auto;\">" + strValue + "</label>");
                                    }
                                    break;
                            }
                            Response.Write("</ul></div>");
                        }
                    }
                %>
                </ext:ContentPanel>
                <ext:ContentPanel ID="ContentPanel1" runat="server" AutoWidth="true" Title="产品详情">
                    <textarea name="UEditor1" id="UEditor1" runat="server"></textarea>
                </ext:ContentPanel>
            </Items>
            <Toolbars>
                <ext:Toolbar ID="Toolbar2" runat="server" Position="footer">
                    <Items>
                        <ext:Button ID="btnSubmit" runat="server" Text="保存" Icon="systemsave" OnClick="btnSubmit_Click"
                            ValidateForms="sfObject">
                        </ext:Button>
                        <ext:ToolbarSeparator ID="ToolbarSeparator2" runat="server">
                        </ext:ToolbarSeparator>
                        <ext:Button ID="btnReset" runat="server" Text="重置" Icon="reload">
                        </ext:Button>
                    </Items>
                </ext:Toolbar>
            </Toolbars>
        </ext:SimpleForm>
        <ext:Window ID="winProdImage" runat="server" Title="产品更多图片管理" EnableCollapse="true"
            Hidden="true" Width="580px" WindowPosition="goldenSection" OnClose="winProdImage_Close" CloseAction="HidePostBack">
            <Items>
                <ext:Grid ID="gridImage" runat="server" EnableRowNumber="true"
                    ShowHeader="false" AutoHeight="true" Height="300px" DataKeyNames="peId" AutoScroll="true"
                    OnRowCommand="gridImage_RowCommand" AllowCellEditing="true">
                    <Columns>
                        <ext:RenderField ID="rfImageName" runat="server" HeaderText="图片名称" DataField="peName" FieldType="string">
                            <Editor>
                                <ext:TextBox ID="txtColorName" runat="server">
                                </ext:TextBox>
                            </Editor>
                        </ext:RenderField>
                        
                        <ext:RenderField ID="rfEnImageName" runat="server" HeaderText="图片英文名" DataField="peEnName" FieldType="string">
                            <Editor>
                                <ext:TextBox ID="txtEnColorName" runat="server">
                                </ext:TextBox>
                            </Editor>
                        </ext:RenderField>
                        
                        <ext:ImageField ID="ImageField1" runat="server" HeaderText="图片" DataImageUrlField="peValue"
                            ImageHeight="60px" />
                        <ext:BoundField ID="BoundField3" runat="server" HeaderText="排序" DataField="peOrder" />
                        <ext:LinkButtonField ID="lbfSave" runat="server" Icon="ApplicationFormEdit" ConfirmText="确定修改？"
                            CommandName="Modify" TextAlign="center" Width="40" />
                        <ext:LinkButtonField ID="lbfDelete" runat="server" Icon="delete" ConfirmText="确定删除？"
                            CommandName="Delete" TextAlign="center" Width="40" />
                    </Columns>
                </ext:Grid>
                <ext:SimpleForm ID="sfImage" runat="server" Title="上传图片" FooterBarAlign="center"
                    BodyPadding="5px">
                    <Items>
                        <ext:HiddenField ID="hfProdCode" runat="server">
                        </ext:HiddenField>
                        <ext:HiddenField ID="hfProdClassId" runat="server" Height="60px">
                        </ext:HiddenField>
                        <ext:FileUpload ID="fuProdImage1" runat="server" Label="选择图片" Required="true" EmptyText="请选择要上传的图片（建议：600*800px)">
                        </ext:FileUpload>
                        <ext:TextBox ID="txtImageName" runat="server" Label="图片名称" Required="true" EmptyText="请填写图片名称">
                        </ext:TextBox>
                        <ext:TextBox ID="txtEnImageName" runat="server" Label="图片英文名" EmptyText="请填写图片英文名">
                        </ext:TextBox>
                        <ext:TextBox ID="txtImageOrder" runat="server" Label="图片排序" Required="true" EmptyText="只能填写数值型"
                            Text="99" Regex="^\d+$">
                        </ext:TextBox>
                    </Items>
                    <Toolbars>
                        <ext:Toolbar runat="server" Position="footer">
                            <Items>
                                <ext:Button ID="btnSaveImage" runat="server" Text="确定上传图片" Icon="systemsave" ValidateForms="sfImage"
                                    OnClick="btnSaveImage_Click">
                                </ext:Button>
                                <ext:Button ID="btnResetImage" runat="server" Text="重 置" Icon="reload">
                                </ext:Button>
                            </Items>
                        </ext:Toolbar>
                    </Toolbars>
                </ext:SimpleForm>
            </Items>
        </ext:Window>
    </form>

    <script type="text/javascript">
        window.UEDITOR_HOME_URL = "<%= ResolveUrl("~/ueditor/") %>";
    </script>

    <script type="text/javascript" src="../ueditor/editor_config.js"></script>

    <script type="text/javascript" src="../ueditor/editor_all.js"></script>
    <script type="text/javascript">
        var editor;
        function onReady() {
            editor = new UE.ui.Editor({
                initialFrameWidth: '100%',
                initialFrameHeight: 350,
                minFrameHeight: 350,
                autoFloatEnabled: false,
                focus: true
            });
            editor.render("<%=UEditor1.ClientID %>");
        }


        // 提交数据之前同步到表单隐藏字段
        X.util.beforeAjaxPostBackScript = function () {
            editor.sync();
        };

        // 更新编辑器内容
        function updateUEditor(content) {
            window.setTimeout(function () {
                editor.setContent(content);
            }, 100);
        }
    </script>

</body>
</html>
